using System.Collections;
using System.Collections.Generic;
using Core;
using Core.Utils;
using UnityEngine;

namespace Game.WeaponComponent {
    public class NormalBulletSpawnerComponent : BaseSpawnerComponent {
        public float Delay = .1f;
        public float Damage = 10.0f;
        public NormalBulletSpawnerComponent(ABSWeaponCombinant combinant) : base(combinant) {
            
        }
        
        protected override void onSpawn() {
            TimerMgr.Ins.AddTask(0, spawnBullet, SpawnNum, Delay,() => mCurCombinant.TriggerCount());
        }

        private void spawnBullet() {
            GameObject bulletObj = PoolMgr.Ins.Spawn("Bullet");
            bulletObj.transform.position = PlayerManager.Ins.CurPlayer.Controller.Hand.position;
            Bullet bullet = bulletObj.AddComponent<Bullet>();
            bullet.Direction = PlayerManager.Ins.CurPlayer.Controller.HandDirection;
            bullet.Speed = 1.0f;
            bullet.Damage = Damage;
            
        }
    }    
}

